//
// Copyright (C) 2011 - 2013  Steve Channell steve.channell@cepheis.com
//
// This file is part of Cephei.QL, an open-source library wrapper 
// arround QuantLib http://quantlib.org/
//
// Cephei.QL is open source software: you can redistribute it and/or modify it
// under the terms of the license.  You should have received a
// copy of the license along with this program; if not, please email
// <support@cepheis.com>. The license is also available online at
// <http://cepheis.com/license.htm>.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE.  See the license for more details.
//
// Version 2.2 with QuantLib 1.2.1
//#include "stdafx.h"
#include "BackwardFlatInterpolation.h"
using namespace Cephei::QL::Math::Interpolations;
#include <gen/QL/Math/Interpolation.h>
using namespace Cephei::QL::Math;
#undef HANDLE
#undef ABSTRACT
#undef STRUCT
Cephei::QL::Math::Interpolations::CBackwardFlatInterpolation::CBackwardFlatInterpolation (boost::shared_ptr<QuantLib::BackwardFlatInterpolation>& childNative, Object^ owner) : CInterpolation(CBackwardFlatInterpolation::typeid)
{
#ifdef HANDLE
	_phBackwardFlatInterpolation = NULL;
#endif
	_ppBackwardFlatInterpolation = &childNative;
    _ppInterpolation = new boost::shared_ptr<QuantLib::Interpolation> (boost::dynamic_pointer_cast<QuantLib::Interpolation> (*_ppBackwardFlatInterpolation));
}
Cephei::QL::Math::Interpolations::CBackwardFlatInterpolation::CBackwardFlatInterpolation (QuantLib::BackwardFlatInterpolation& childNative, Object^ owner) : CInterpolation(CBackwardFlatInterpolation::typeid)
{
#ifdef HANDLE
	_phBackwardFlatInterpolation = NULL;
#endif
	_ppBackwardFlatInterpolation = new boost::shared_ptr<QuantLib::BackwardFlatInterpolation> (&childNative);
    _ppInterpolation = new boost::shared_ptr<QuantLib::Interpolation> (boost::dynamic_pointer_cast<QuantLib::Interpolation> (*_ppBackwardFlatInterpolation));
    _BackwardFlatInterpolationOwner = owner;
    _InterpolationOwner = owner;
}

Cephei::QL::Math::Interpolations::CBackwardFlatInterpolation::CBackwardFlatInterpolation (CBackwardFlatInterpolation^ copy) : CInterpolation(CBackwardFlatInterpolation::typeid)
{
#ifdef HANDLE
	_phBackwardFlatInterpolation = NULL;
#endif
	if (copy->HasNative() != NULL)
    {
		_ppBackwardFlatInterpolation = new boost::shared_ptr<QuantLib::BackwardFlatInterpolation> (copy->GetShared());
        _ppInterpolation = new boost::shared_ptr<QuantLib::Interpolation> (boost::dynamic_pointer_cast<QuantLib::Interpolation> (*_ppBackwardFlatInterpolation));
    }
}
Cephei::QL::Math::Interpolations::CBackwardFlatInterpolation::CBackwardFlatInterpolation (PLATFORM::Type^ t) : CInterpolation(CBackwardFlatInterpolation::typeid)
{
#ifdef HANDLE
	_phBackwardFlatInterpolation = NULL;
#endif
	if (!t->IsSubclassOf(CBackwardFlatInterpolation::typeid))
		throw REFNEW Exception ("Invalid base-case init");
}
#ifdef HANDLE
Cephei::QL::Math::Interpolations::CBackwardFlatInterpolation::CBackwardFlatInterpolation (QuantLib::Handle<QuantLib::BackwardFlatInterpolation>& childNative, Object^ owner)  : CInterpolation(CBackwardFlatInterpolation::typeid)
{
	_phBackwardFlatInterpolation = &childNative;
	_ppBackwardFlatInterpolation = &static_cast<boost::shared_ptr<QuantLib::BackwardFlatInterpolation>>(childNative.currentLink());
    _ppInterpolation = new boost::shared_ptr<QuantLib::Interpolation> (boost::dynamic_pointer_cast<QuantLib::Interpolation> (*_ppBackwardFlatInterpolation));
    _BackwardFlatInterpolationOwner = owner;
}
Cephei::QL::Math::Interpolations::CBackwardFlatInterpolation::CBackwardFlatInterpolation (QuantLib::Handle<QuantLib::BackwardFlatInterpolation> childNative)  : CInterpolation(CBackwardFlatInterpolation::typeid)
{
	_phBackwardFlatInterpolation = &childNative;
	_ppBackwardFlatInterpolation = &static_cast<boost::shared_ptr<QuantLib::BackwardFlatInterpolation>>(childNative.currentLink());
    _ppInterpolation = new boost::shared_ptr<QuantLib::Interpolation> (boost::dynamic_pointer_cast<QuantLib::Interpolation> (*_ppBackwardFlatInterpolation));
}
#endif
#ifdef STRUCT
Cephei::QL::Math::Interpolations::CBackwardFlatInterpolation::CBackwardFlatInterpolation (QuantLib::BackwardFlatInterpolation childNative)  : CInterpolation(CBackwardFlatInterpolation::typeid)
{
#ifdef HANDLE
	_phBackwardFlatInterpolation = NULL;
#endif
	_ppBackwardFlatInterpolation = new boost::shared_ptr<QuantLib::BackwardFlatInterpolation> (new QuantLib::BackwardFlatInterpolation (childNative));
    _ppInterpolation = new boost::shared_ptr<QuantLib::Interpolation> (boost::dynamic_pointer_cast<QuantLib::Interpolation> (*_ppBackwardFlatInterpolation));
}
#endif

Cephei::QL::Math::Interpolations::CBackwardFlatInterpolation::~CBackwardFlatInterpolation ()
{
    if (_ppBackwardFlatInterpolation != NULL)
    {
	    delete _ppBackwardFlatInterpolation;
        _ppBackwardFlatInterpolation = NULL;
    }
}
Cephei::QL::Math::Interpolations::CBackwardFlatInterpolation::!CBackwardFlatInterpolation ()
{
    if (_ppBackwardFlatInterpolation != NULL)
    {
	    delete _ppBackwardFlatInterpolation;
    }
}
QuantLib::BackwardFlatInterpolation& Cephei::QL::Math::Interpolations::CBackwardFlatInterpolation::GetReference ()
{
    if (_ppBackwardFlatInterpolation == NULL) throw REFNEW NativeNullException ();
	return **_ppBackwardFlatInterpolation;
}
boost::shared_ptr<QuantLib::BackwardFlatInterpolation>& Cephei::QL::Math::Interpolations::CBackwardFlatInterpolation::GetShared ()
{
    if (_ppBackwardFlatInterpolation == NULL) throw REFNEW NativeNullException ();
	return *_ppBackwardFlatInterpolation;
}
QuantLib::BackwardFlatInterpolation* Cephei::QL::Math::Interpolations::CBackwardFlatInterpolation::GetPointer ()
{
    if (_ppBackwardFlatInterpolation == NULL) throw REFNEW NativeNullException ();
	return &**_ppBackwardFlatInterpolation;
}
#ifdef HANDLE
QuantLib::Handle<QuantLib::BackwardFlatInterpolation>& Cephei::QL::Math::Interpolations::CBackwardFlatInterpolation::GetHandle ()
{
	if (_phBackwardFlatInterpolation == NULL)
	{
		_phBackwardFlatInterpolation = new Handle<QuantLib::BackwardFlatInterpolation> (*_ppBackwardFlatInterpolation);
	}
	return *_phBackwardFlatInterpolation;
}
#endif
bool Cephei::QL::Math::Interpolations::CBackwardFlatInterpolation::HasNative () 
{
	return (_ppBackwardFlatInterpolation != NULL);
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Factory class

